let app = getApp()
Component({ 
    properties: {
         pagetitle:String
      },
      data:{
        list: [],
        page_path: "pages/services/order/list/index",
        currentData: 0,
        clientHeight: "",
        page: 1,
        end:true,
        status: 0,
        detail: {}
      },
    lifetimes: {
        attached: function () {
           this.get_data();
           var that=this
           wx.getSystemInfo({
            success: function(t) {
                 that.setData({
                  clientHeight:t.windowHeight
                 })
            }
        })
       }
      },
    methods: {
       toorderinfo:function(e){
        wx.navigateTo({
            url: '/yb_shopv2/native/all/index?type=services_order_info&orderid='+e.currentTarget.dataset.id,
          }) 
      },
        choosetab:function(e){
          this.setData({
            currentData:e.currentTarget.dataset.current,
            status: e.currentTarget.dataset.status
          })
          this.get_data();
        },
        cancelorder:function(e){
          var id=e.currentTarget.dataset.id
          var that=this
          wx.showModal({
            title: '提示',
            content: '确认是否取消？',
            showCancel: true,
            cancelText:"取消",
            confirmText:"确定",
            success: function (res) {
              if (res.cancel) {
              } else{
                wx.request({
                  url: app.globalData.siteroot,
                  data: {
                    do:'Services_updOrderStatus',
                    user_id:wx.getStorageSync('user_id'),
                    id:id,
                    status:4
                  },
                  success: function(res) {
                    wx.showToast({
                      title: '取消成功！',
                      icon: 'none',
                      duration: 1500
                    })
                    that.get_data();
                  }
                })
              }
             },
             fail: function (res) { },
             complete: function (res) { }
        })
        },
        get_data:function(){
          var that=this
          wx.request({
              url: app.globalData.siteroot,
              data: {
                do:'Services_getAllOrder',
                user_id:wx.getStorageSync('user_id'),
                staff_id:wx.getStorageSync('staff_bind_id'),
                page:that.data.page,
                status:that.data.status
              },
              success: function(res) {
                 that.setData({
                  list:res.data.info
                 })
              }
            })
        }
    }
});
